package com.matchmaking.system.service.impl;


import com.matchmaking.system.config.R;
import com.matchmaking.system.domain.SysMenu;
import com.matchmaking.system.domain.vo.SysMenuEchartsVo;
import com.matchmaking.system.mapper.SysMenuMapper;
import com.matchmaking.system.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.rmi.MarshalledObject;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class SysMenuServiceImpl implements SysMenuService {

    @Autowired
    SysMenuMapper sysMenuMapper;

    @Override
    public List<SysMenu> list(SysMenu sysMenu) {
        List<SysMenu> list = sysMenuMapper.list(sysMenu);
        for (SysMenu menu : list) {
            if (menu.getStatus().equals("1")){
                menu.setStatuss(false);
            }else {
                menu.setStatuss(true);
            }
        }
        return list;
    }

    @Override
    public List<SysMenu> getSonMenu(Long id) {
        return sysMenuMapper.getSonMenu(id);
    }

    @Override
    public void updateStatusById(Long id, int i) {
        sysMenuMapper.updateStatusById(id,i);
    }

    @Override
    public List<SysMenu> getParentMenu() {
        return sysMenuMapper.getParentMenu();
    }

    @Override
    public Long getIdByName(String name) {
        return sysMenuMapper.getIdByName(name);
    }

    @Override
    public void insertMenu(SysMenu sysMenu) {
        sysMenuMapper.insertMenu(sysMenu);
    }

    @Override
    public String getNameByParentId(Integer parentId) {
        return sysMenuMapper.getNameByParentId(parentId);
    }

    @Override
    public boolean updateById(SysMenu sysMenu) {
      Integer i =  sysMenuMapper.updateById(sysMenu);
      if (i>0){
          return true;
      }else {
          return false;
      }

    }

    @Override
    public  List<SysMenuEchartsVo> getNumByMenuType() {
        List<SysMenuEchartsVo> list=sysMenuMapper.getNumByMenuType();

        return list;
    }

    @Override
    public void delById(Long id) {
        sysMenuMapper.delById(id);
    }
}
